<?xml version="1.0" encoding="UTF-8"?>


<!--
	xhtml.inc.xsl

	template per la creazione di elementi XHTML.
-->


<xsl:stylesheet
	version = "1.0"
	xmlns = "http://www.w3.org/1999/xhtml"
	xmlns:inc = "http://ltw0807.web.cs.unibo.it/xsl/inc"
	xmlns:xsl = "http://www.w3.org/1999/XSL/Transform">


	<!--
		Template inc:create-output-markers

		Crea gli attributi class='marcatore-poliwiki'
		e id = 'nome-elemento'.

		Per i discendenti di <metadati> usa title al posto di id.

		Copia tutti gli attributi js presenti.
	-->
	<xsl:template name = "inc:create-output-markers">
		<xsl:choose>
			<xsl:when test = "ancestor-or-self::metadati">
				<xsl:attribute name = "title">
					<xsl:value-of select = "local-name()"/>
				</xsl:attribute>
			</xsl:when>
			<xsl:otherwise>
				<xsl:attribute name = "id">
					<xsl:value-of select = "local-name()"/>
				</xsl:attribute>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:attribute name = "class">
			<xsl:text>marcatore-poliwiki</xsl:text>
		</xsl:attribute>
	</xsl:template>


	<!--
		Template inc:create-link-css

		Crea l'elemento <link> per l'inserimento del css.
	-->
	<xsl:template name = "inc:create-link-css">

		<!-- URL assoluto del fil css.  -->
		<xsl:param name = "css-url"/>

		<xsl:element name = "link">
			<xsl:attribute name = "rel">
				<xsl:text>stylesheet</xsl:text>
			</xsl:attribute>
			<xsl:attribute name = "type">
				<xsl:text>text/css</xsl:text>
			</xsl:attribute>
			<xsl:attribute name = "href">
				<xsl:value-of select = "$css-url"/>
			</xsl:attribute>
		</xsl:element>
	</xsl:template>


	<!--
		Template inc:create-comma-list

		Crea le virgole.
	-->
	<xsl:template name = "inc:create-comma-list">
		<xsl:if test = "position() &lt; last()">
			<xsl:text>, </xsl:text>
		</xsl:if>
	</xsl:template>


	<!--
		Template inc:create-comma-and-list

		Crea le virgole e alla fine la congiunzione 'e'.
	-->
	<xsl:template name = "inc:create-comma-and-list">
		<xsl:choose>
			<xsl:when test = "position() = last()"/>
			<xsl:when test = "position() = last() - 1">
				<xsl:text> e </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>, </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!--
		Template inc:copy-js-attr
	-->
	<xsl:template name = "inc:copy-js-attr">
		<xsl:copy-of select = "@onclick | @ondblclick | @onmousedown | @onmouseup | @onmouseover | @onmousemove | @onmouseout | @onkeypress | @onkeydown | @onkeyup"/>
	</xsl:template>

</xsl:stylesheet>
